package com.jollychic.www.roomdatebasedemo.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;

import com.jollychic.www.roomdatebasedemo.model.DrinksEntity;
import com.jollychic.www.roomdatebasedemo.model.result.InnerResultModel;

import java.util.List;

/**
 * desc:  <br/>
 * author: 李超杰 <br/>
 * date: 2018/5/20 下午4:46 <br/>
 * since v <br/>
 */
@Dao
public interface IDrinkDao {

//    sqlite3可以有多种多表查询方法，比如  select (select * from table2)  from table1 where xxx=xxx;
//
//    这种方法比较简单并且高效：
//
//    select table1.abc from table1,table2 where table1.xxx=table2.xxx;
//
//    或这种
//
//    select table1.abc from table1 inner join table2 on table1.xxx=table2.xxx;

    @Query("select * from Drinks")
    List<DrinksEntity> queryDrinks();

    //启用内联查询
    @Query("select store_id,drinkPrice,drinkBrand,drinksId,storeName from Stores inner join drinks on Stores.storeId = drinks.store_id ")
    List<InnerResultModel> queryMul();

    @Insert
    void insert(List<DrinksEntity> list);
}
